package com.rui.controller;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.poi.word.Word07Writer;
import com.rui.domain.*;
import com.rui.service.AcademicService;
import com.rui.service.InternshipService;
import com.rui.service.JobService;
import com.rui.service.TeacherService;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.io.*;
import java.io.File;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;

@Controller
@SuppressWarnings("all")
@RequestMapping("/academic")
public class AcademicController {

    private static final String STUNO = "学号";
    private static final String NAME = "姓名";
    private static final String COMPANYNAME = "公司名称";
    private static final String COMPANYCODE = "公司统一信用代码";
    private static final String CITY = "所在城市";
    private static final String ADDRESS = "详细地址";
    private static final String STATION = "任职岗位";
    private static final String DEPARTMENT = "所属部门";
    private static final String PRINCIPALNAME = "负责人名称";
    private static final String PRINCIPALPHONE = "负责人电话";
    private static final String ENTRYTIME = "入职时间";
    private static final String RESIGNATIONTIME = "离职时间";
    private static final String ATTENDANCETIME = "上班时间";
    private static final String CLOSINGTIME = "下班时间";
    private static final String SALARY = "工资(月薪)";
    private static final String WEAL = "福利";
    private static final String DEVELOPMENTLANGUAGE = "开发语言";
    private static final String DATABASE = "数据库";
    private static final String FRAME = "框架";
    private static final String REMARK = "备注";
    private static final String STU_INTERNSHIP = "学生实习信息";

    private static final String INTERNSHIPEXCEL = "实习数据表.xls";
    private static final String JOBEXCEL = "就业数据表.xls";
    private static final String LOGGERZIP = "实习日志.zip";

    private static final String PASSWORD = "111111";
    private static final String SALT = "encrypt";

    private static final String STR_DATA = "data";
    private static final String STR_COUNT = "count";
    private static final String STR_CODE = "code";
    private static final String STR_MSG = "msg";

    private static final String WORD = ".docx";

    @Autowired
    private TeacherService teacherService;
    @Autowired
    private AcademicService academicService;
    @Autowired
    private InternshipService internshipService;
    @Autowired
    private JobService jobService;

    @RequestMapping("/index")
    public String index() {
        return "academic/index";
    }

    @RequestMapping("/toInputTeacherInfo.action")
    public String toInputTeacherInfo() {
        return "academic/inputTeacherInfo";
    }

    @GetMapping("/toShowStudentInternshipInfo.action")
    public String toShowStudentInternshipInfo() {
        return "academic/showStudentInternshipInfo";
    }

    @GetMapping("/getStudentInternshipInfo.action")
    @ResponseBody
    public Map<String, Object> getStudentInternshipInfo(String grade) {
        Map<String, Object> map = new HashMap<>();
        if (grade == null || grade.length() == 0) {
            Calendar calendar = Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            grade = String.valueOf(year);
        }
        List<InternshipVO> internshipList = internshipService.findAll(grade);
        map.put(STR_DATA, internshipList);
        map.put(STR_COUNT, internshipList.size());
        map.put(STR_CODE, 0);
        map.put(STR_MSG, "没有查询到学生实习信息");
        return map;
    }

    @RequestMapping("/addTeacher.action")
    @ResponseBody
    public Map<String, Object> addTeacher(Teacher teacher, HttpSession session) {
        Map<String, Object> map = new HashMap<>();
        //System.out.println(teacher);
        Md5Hash password = new Md5Hash(PASSWORD, SALT, 3);
        User user = new User();
        user.setId(UUID.randomUUID().toString());
        user.setUsername(teacher.getJobNo());
        user.setPassword(password.toString());
        user.setRoleId(2);
        user.setSalt(SALT);
        boolean b = teacherService.addTeacher(teacher, user);
        if (b) {
            map.put("flag", true);
        } else {
            map.put("flag", false);
        }
        return map;
    }

    @RequestMapping("/toShowTeacherInfo.action")
    public String toShowTeacherInfo() {
        return "academic/showTeacherInfo";
    }

    @RequestMapping("/getTeacherInfo.action")
    @ResponseBody
    public Map<String, Object> getTeacherInfo(HttpSession session) {
        Map<String, Object> map = new HashMap<>();
        Academic academic = (Academic) session.getAttribute("academic");
        List<Teacher> teacherList = teacherService.findAllTeachersAndAcademices();
        map.put("data", teacherList);
        map.put("count", teacherList.size());
        map.put("code", 0);
        map.put("msg", "没有查询到教师信息");
        return map;
    }

    @RequestMapping("/deleteTeacher.action")
    @ResponseBody
    public Map<String, Object> deleteTeacher(String jobNo) {
        Map<String, Object> map = new HashMap<>();
        //System.out.println(stuNo);
        boolean b = teacherService.deleteTeacher(jobNo);
        if (b) {
            map.put("flag", true);
        } else {
            map.put("flag", false);
        }
        return map;
    }

    @RequestMapping("/updateTeacher.action")
    @ResponseBody
    public Map<String, Object> updateTeacher(Teacher teacher) {
        Map<String, Object> map = new HashMap<>();
        boolean b = teacherService.updateTeacher(teacher);
        if (b) {
            map.put("flag", true);
        } else {
            map.put("flag", false);
        }
        return map;
    }

    @RequestMapping("/getPersonInfo.action")
    @ResponseBody
    public Map<String, Object> getPersonInfo(HttpSession session) {
        Map<String, Object> map = new HashMap<>();
        Academic academic = (Academic) session.getAttribute("academic");
        //System.out.println(academic);
        academic = academicService.findAcademicByJobNo(academic.getJobNo());
        if (academic == null) {
            return null;
        }
        map.put("academic", academic);
        return map;
    }

    @RequestMapping("/updatePerson.action")
    @ResponseBody
    public Map<String, Object> updatePerson(Academic academic) {
        Map<String, Object> map = new HashMap<>();
        //System.out.println("/updatePerson.action" + academic);
        boolean b = academicService.updateAcademic(academic);
        System.out.println(b);
        if (b) {
            map.put("flag", true);
        } else {
            map.put("flag", false);
        }
        return map;
    }

    @RequestMapping("/toExportInternshipInfo.action")
    public String toExportInternship() {
        return "academic/exportInternshipInfo";
    }

    @RequestMapping("/exportInternship.action")
    @ResponseBody
    public void exportInternshipInfo(String yearSelector) throws IOException {
        //获取response对象
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        //获取数据
        List<InternshipVO> internshipList = academicService.findInternshipByYear(yearSelector);
        if (internshipList.size() == 0) {
            return;
        }
        ServletOutputStream os = response.getOutputStream();
        //创建writer
        ExcelWriter writer = ExcelUtil.getWriter();
        writer.renameSheet(STU_INTERNSHIP);
        //自定义标题别名
        writer.addHeaderAlias("stuNo", STUNO);
        writer.addHeaderAlias("name", NAME);
        writer.addHeaderAlias("companyName", COMPANYNAME);
        writer.addHeaderAlias("companyCode", COMPANYCODE);
        writer.addHeaderAlias("city", CITY);
        writer.addHeaderAlias("address", ADDRESS);
        writer.addHeaderAlias("station", STATION);
        writer.addHeaderAlias("department", DEPARTMENT);
        writer.addHeaderAlias("principalName", PRINCIPALNAME);
        writer.addHeaderAlias("principalPhone", PRINCIPALPHONE);
        writer.addHeaderAlias("entryTime", ENTRYTIME);
        writer.addHeaderAlias("resignationTime", RESIGNATIONTIME);
        writer.addHeaderAlias("attendanceTime", ATTENDANCETIME);
        writer.addHeaderAlias("closingTime", CLOSINGTIME);
        writer.addHeaderAlias("salary", SALARY);
        writer.addHeaderAlias("weal", WEAL);
        writer.addHeaderAlias("developmentLanguage", DEVELOPMENTLANGUAGE);
        writer.addHeaderAlias("dataBase", DATABASE);
        writer.addHeaderAlias("frame", FRAME);
        writer.addHeaderAlias("remark", REMARK);
        writer.setOnlyAlias(true);
        //写出内容
        writer.write(internshipList, true);
        writer.autoSizeColumnAll();
        //清空response
        response.reset();
        //设置response的header
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(INTERNSHIPEXCEL, "UTF-8"));
        response.setContentType("application/msexcel");
        writer.flush(os);
        //关闭资源
        os.close();
        writer.close();

    }

    @RequestMapping("/toShowStudentInternshipDataAnalyse.action")
    public String toShowStudentInternshipDataAnalyse() {
        return "academic/showStudentInternshipDataAnalyse";
    }

    @RequestMapping("/getDevelopmentLanguageData.action")
    @ResponseBody
    public Map<String, Object> getDevelopmentLanguageData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        List<CountDTO> thisYearDevelopmentLanguageList = academicService.getDevelopmentLanguageCount(year);
        DevelopmentLanguageVO thisYearDevelopmentLanguage = setDevelopmentLanguageVO(thisYearDevelopmentLanguageList);
        echartsVO.setThisYear(thisYearDevelopmentLanguage);

        List<CountDTO> lastYearDevelopmentLanguageList = academicService.getDevelopmentLanguageCount(year - 1);
        DevelopmentLanguageVO lastYearDevelopmentLanguage = setDevelopmentLanguageVO(lastYearDevelopmentLanguageList);
        echartsVO.setLastYear(lastYearDevelopmentLanguage);

        List<CountDTO> beforeLastDevelopmentLanguageList = academicService.getDevelopmentLanguageCount(year - 2);
        DevelopmentLanguageVO beforeLastDevelopmentLanguage = setDevelopmentLanguageVO(beforeLastDevelopmentLanguageList);
        echartsVO.setYearBeforeLast(beforeLastDevelopmentLanguage);

        map.put(STR_DATA, echartsVO);
        return map;
    }

    private static DevelopmentLanguageVO setDevelopmentLanguageVO(List<CountDTO> dtoList) {
        DevelopmentLanguageVO vo = new DevelopmentLanguageVO();
        if (dtoList != null && dtoList.size() > 0) {
            dtoList.forEach(dto -> {
                if ("C".equals(dto.getLanguageName())) {
                    vo.setC(dto.getCount());
                } else if ("C++".equals(dto.getLanguageName())) {
                    vo.setCAdd(dto.getCount());
                } else if ("Java".equals(dto.getLanguageName())) {
                    vo.setJava(dto.getCount());
                } else if ("JavaScript".equals(dto.getLanguageName())) {
                    vo.setJavaScript(dto.getCount());
                } else if ("PHP".equals(dto.getLanguageName())) {
                    vo.setPhp(dto.getCount());
                } else if ("Python".equals(dto.getLanguageName())) {
                    vo.setPython(dto.getCount());
                } else if ("其他".equals(dto.getLanguageName())) {
                    vo.setOther(dto.getCount());
                }
            });
        }
        return vo;
    }

    @RequestMapping("/getDataBaseData.action")
    @ResponseBody
    public Map<String, Object> getDataBaseData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        List<CountDTO> thisYearDataBaseCountList = academicService.getDataBaseCount(year);
        DataBaseVO thisYearDataBase = setDataBaseVO(thisYearDataBaseCountList);
        echartsVO.setThisYearDataBase(thisYearDataBase);

        List<CountDTO> lastYearDataBaseCountList = academicService.getDataBaseCount(year - 1);
        DataBaseVO lastYearDataBase = setDataBaseVO(lastYearDataBaseCountList);
        echartsVO.setLastYearDataBase(lastYearDataBase);

        List<CountDTO> beforeLastDataBaseCountList = academicService.getDataBaseCount(year - 2);
        DataBaseVO beforeLastYearDataBase = setDataBaseVO(beforeLastDataBaseCountList);
        echartsVO.setYearBeforeLastDataBase(beforeLastYearDataBase);

        map.put(STR_DATA, echartsVO);
        return map;
    }

    private static DataBaseVO setDataBaseVO(List<CountDTO> dtoList) {
        DataBaseVO vo = new DataBaseVO();
        if (dtoList != null && dtoList.size() > 0) {
            dtoList.forEach(dto -> {
                if ("MySQL".equals(dto.getLanguageName())) {
                    vo.setMysql(dto.getCount());
                } else if ("Oracle".equals(dto.getLanguageName())) {
                    vo.setOracle(dto.getCount());
                } else if ("SQL Server".equals(dto.getLanguageName())) {
                    vo.setSqlServer(dto.getCount());
                } else if ("DB2".equals(dto.getLanguageName())) {
                    vo.setDb2(dto.getCount());
                } else if ("Sybase".equals(dto.getLanguageName())) {
                    vo.setSybase(dto.getCount());
                } else if ("PostgreSQL".equals(dto.getLanguageName())) {
                    vo.setPostgreSQL(dto.getCount());
                } else if ("其他".equals(dto.getLanguageName())) {
                    vo.setOther(dto.getCount());
                }
            });
        }
        return vo;
    }

    @RequestMapping("/getSalaryData.action")
    @ResponseBody
    public Map<String, Object> getSalaryData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        SalaryVO thisYearSalary = academicService.getSalaryCount(year);
        echartsVO.setThisYearSalary(thisYearSalary);

//        SalaryVO lastYearSalary = academicService.getSalaryCount(Calendar.getInstance().get(Calendar.YEAR)-1);
//        echartsVO.setLastYearSalary(lastYearSalary);

//        SalaryVO beforeLastYearSalary = academicService.getSalaryCount(Calendar.getInstance().get(Calendar.YEAR)-2);
//        echartsVO.setYearBeforeLastSalary(beforeLastYearSalary);

        map.put(STR_DATA, echartsVO);
        return map;
    }

    @RequestMapping("/getInternshipRateData.action")
    @ResponseBody
    public Map<String, Object> getInternshipRateData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        //获取当前年份毕业生总人数
        Long studentTotal = academicService.getStudentTotal(year);
        echartsVO.setYearTotal(studentTotal);
        //获取已经实习的毕业生人数
        Long internshipCount = academicService.getInternshipCount(year);
        echartsVO.setYearCount(internshipCount);
        if (studentTotal >= internshipCount) {
            echartsVO.setNoYearCount(studentTotal - internshipCount);
        }

        map.put(STR_DATA, echartsVO);
        return map;
    }

    @RequestMapping("/toShowInternshipLoggerList.action")
    public String toShowInternshipLoggerList() {
        return "academic/showInternshipLoggerList";
    }

    @RequestMapping("/getInternshipLoggerList.action")
    @ResponseBody
    public Map<String, Object> getInternshipLoggerList(String year) {
        Map<String, Object> map = new HashMap<>();
        if (ObjectUtil.isEmpty(year)) {
            year = Calendar.getInstance().get(Calendar.YEAR) + "";
        }

        //获取学生实习日志信息  学号、姓名、系、专业、日志篇数、完成状态、批改篇数、批改完成状态
        List<InternshipLoggerInfoVO> internshipLoggerList = academicService.getInternshipLoggerList(Integer.valueOf(year));
        internshipLoggerList.stream().forEach(i -> {
            if (i.getLoggerCount() >= 4) {
                i.setLoggerStatus(true);
            }
            if (i.getCheckCount() == i.getLoggerCount()) {
                i.setCheckStatus(true);
            }
        });
        map.put(STR_DATA, internshipLoggerList);
        if (internshipLoggerList != null && internshipLoggerList.size() == 0) {
            map.put(STR_MSG, "没有查询到数据");
        }
        map.put(STR_COUNT, internshipLoggerList.size());
        map.put(STR_CODE, 0);
        return map;
    }

    @RequestMapping("/exportInternshipLogger.action")
    @ResponseBody
    public void exportInternshipLogger(String[] stuNoArray) throws IOException {
        if(stuNoArray.length == 0) {
            return;
        }
        //先创建一个文件夹对象
        File loggerDir = FileUtil.file("loggerDir");
        if (!loggerDir.exists()) {
            loggerDir.mkdirs();
        }
        //批量查询学生实习日志信息
        List<InternshipLoggerInfoVO> internshipLoggerList = academicService.findInternshipLoggerByStuNos(stuNoArray);
        Map<String, List<InternshipLoggerInfoVO>> map = internshipLoggerList.parallelStream().collect(
                Collectors.groupingBy(internshipLoggerInfoVO -> internshipLoggerInfoVO.getStudentNumber())
        );
        Set<String> keySet = map.keySet();
        keySet.forEach(k -> {
            List<InternshipLoggerInfoVO> list = map.get(k);
            //创建每个学生的文件夹名称 学号_名称
            list.forEach(l -> {
                if ("已阅".equals(l.getStatus())) {
                    String folder = l.getStudentNumber() + "_" + l.getStuName();
                    Word07Writer writer = new Word07Writer();
                    //对日志内容进行解析
                    String content = l.getContent()
                            .replaceAll("&nbsp;", "")
                            .replaceAll("<p>", "")
                            .replaceAll("<span>", "")
                            .replaceAll("</span>", "")
                            .replaceAll("<b>", "")
                            .replaceAll("</b>", "")
                            .replaceAll("<p style=\"text-align: left;\">", "");
                    String[] split = content.split("</p>");
                    //添加标题
                    writer.addText(ParagraphAlignment.CENTER, new Font("黑体", Font.BOLD, 15), "毕业实习日志");
                    writer.addText(new Font("宋体", Font.PLAIN, 10), "");
                    //学生信息 系（部）：计算机系  专业（方向）：计算机科学与技术  学号：1840706310  姓名：陈锐恒
                    String info = "系（部）：" + l.getDepartment() + "      专业（方向）："
                            + l.getMajor() + "      学号：" + l.getStudentNumber() + "      姓名：" + l.getStuName();
                    writer.addText(new Font("楷体_GB2312", Font.PLAIN, 10), info);
                    writer.addText(new Font("宋体", Font.PLAIN, 10), "");
                    // 添加段落（正文）
                    for (String str : split) {
                        writer.addText(new Font("宋体", Font.PLAIN, 10), str);
                    }
                    writer.addText(new Font("宋体", Font.PLAIN, 10), "");

                    //评语评分
                    String comment = "评语：" + l.getComment();
                    writer.addText(new Font("宋体", Font.PLAIN, 10), comment);
                    String grade = "评分：" + l.getGrade();
                    writer.addText(new Font("宋体", Font.PLAIN, 10), grade);
                    writer.addText(new Font("宋体", Font.PLAIN, 10), "");
                    //指导老师信息
                    String teacherInfo = "毕业实习指导教师签字：" + l.getTeaName();
                    writer.addText(new Font("仿宋_GB2312", Font.PLAIN, 10), teacherInfo);
                    //日期
                    String date = "                                                               " +
                            "                                                                         "
                            + new SimpleDateFormat("yyyy年MM月dd日").format(l.getUpdateTime());
                    writer.addText(new Font("仿宋_GB2312", Font.PLAIN, 10), date);
                    // 写出到文件
                    String filePath = loggerDir.getPath() + "/" + folder + "/" + l.getName() + WORD;
                    writer.flush(FileUtil.file(filePath));
                    writer.close();
                }
            });
        });
        File zip = ZipUtil.zip(loggerDir);
        if (!zip.exists()){
            zip.mkdir();
        }
        //获取response对象
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        //清空response
        response.reset();
        //设置response的header
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(LOGGERZIP, "UTF-8"));
        response.setContentType("application/x-zip-compressed");

        OutputStream outputStream = response.getOutputStream();
        InputStream inputStream = new FileInputStream(zip);

        byte[] b = new byte[1024];
        int len = 0;
        while ((len=inputStream.read(b))>0) {
            outputStream.write(b,0,len);
            outputStream.flush();
        }
        inputStream.close();
        outputStream.close();
        //最后把保存在项目的临时文件删除掉
        FileUtil.del(loggerDir);
        FileUtil.del(zip);

    }

    @GetMapping("/toShowStudentJobInfo.action")
    public String toShowStudentJobnfo() {
        return "academic/showStudentJobInfo";
    }

    @GetMapping("/getStudentJobInfo.action")
    @ResponseBody
    public Map<String, Object> getStudentJobInfo(String grade) {
        Map<String, Object> map = new HashMap<>();
        if (grade == null || grade.length() == 0) {
            Calendar calendar = Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            grade = String.valueOf(year);
        }
        List<JobVO> jobList = jobService.findAll(grade);
        map.put(STR_DATA, jobList);
        map.put(STR_COUNT, jobList.size());
        map.put(STR_CODE, 0);
        map.put(STR_MSG, "没有查询到学生就业信息");
        return map;
    }

    @RequestMapping("/exportJob.action")
    @ResponseBody
    public void exportJob(String yearSelector) throws IOException {
        //获取response对象
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        //获取数据
        List<JobVO> jobList = jobService.findAll(yearSelector);
        if (jobList.size() == 0) {
            return;
        }
        ServletOutputStream os = response.getOutputStream();
        //创建writer
        ExcelWriter writer = ExcelUtil.getWriter();
        writer.renameSheet(STU_INTERNSHIP);
        //自定义标题别名
        writer.addHeaderAlias("stuNo", STUNO);
        writer.addHeaderAlias("name", NAME);
        writer.addHeaderAlias("companyName", COMPANYNAME);
        writer.addHeaderAlias("companyCode", COMPANYCODE);
        writer.addHeaderAlias("city", CITY);
        writer.addHeaderAlias("address", ADDRESS);
        writer.addHeaderAlias("station", STATION);
        writer.addHeaderAlias("department", DEPARTMENT);
        writer.addHeaderAlias("entryTime", ENTRYTIME);
        writer.addHeaderAlias("resignationTime", RESIGNATIONTIME);
        writer.addHeaderAlias("attendanceTime", ATTENDANCETIME);
        writer.addHeaderAlias("closingTime", CLOSINGTIME);
        writer.addHeaderAlias("salary", SALARY);
        writer.addHeaderAlias("weal", WEAL);
        writer.addHeaderAlias("developmentLanguage", DEVELOPMENTLANGUAGE);
        writer.addHeaderAlias("dataBase", DATABASE);
        writer.addHeaderAlias("frame", FRAME);
        writer.addHeaderAlias("remark", REMARK);
        writer.setOnlyAlias(true);
        //写出内容
        writer.write(jobList, true);
        writer.autoSizeColumnAll();
        //清空response
        response.reset();
        //设置response的header
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(JOBEXCEL, "UTF-8"));
        response.setContentType("application/msexcel");
        writer.flush(os);
        //关闭资源
        os.close();
        writer.close();

    }

    @RequestMapping("/toShowStudentJobDataAnalyse.action")
    public String toShowStudentJobDataAnalyse() {
        return "academic/showStudentJobDataAnalyse";
    }

    @RequestMapping("/getJobDevelopmentLanguageData.action")
    @ResponseBody
    public Map<String, Object> getJobDevelopmentLanguageData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        List<CountDTO> thisYearDevelopmentLanguageList = academicService.getJobDevelopmentLanguageCount(year);
        DevelopmentLanguageVO thisYearDevelopmentLanguage = setDevelopmentLanguageVO(thisYearDevelopmentLanguageList);
        echartsVO.setThisYear(thisYearDevelopmentLanguage);

        List<CountDTO> lastYearDevelopmentLanguageList = academicService.getJobDevelopmentLanguageCount(year - 1);
        DevelopmentLanguageVO lastYearDevelopmentLanguage = setDevelopmentLanguageVO(lastYearDevelopmentLanguageList);
        echartsVO.setLastYear(lastYearDevelopmentLanguage);

        List<CountDTO> beforeLastDevelopmentLanguageList = academicService.getJobDevelopmentLanguageCount(year - 2);
        DevelopmentLanguageVO beforeLastDevelopmentLanguage = setDevelopmentLanguageVO(beforeLastDevelopmentLanguageList);
        echartsVO.setYearBeforeLast(beforeLastDevelopmentLanguage);

        map.put(STR_DATA, echartsVO);
        return map;
    }

    @RequestMapping("/getJobDataBaseData.action")
    @ResponseBody
    public Map<String, Object> getJobDataBaseData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        List<CountDTO> thisYearDataBaseCountList = academicService.getJobDataBaseCount(year);
        DataBaseVO thisYearDataBase = setDataBaseVO(thisYearDataBaseCountList);
        echartsVO.setThisYearDataBase(thisYearDataBase);

        List<CountDTO> lastYearDataBaseCountList = academicService.getJobDataBaseCount(year - 1);
        DataBaseVO lastYearDataBase = setDataBaseVO(lastYearDataBaseCountList);
        echartsVO.setLastYearDataBase(lastYearDataBase);

        List<CountDTO> beforeLastDataBaseCountList = academicService.getJobDataBaseCount(year - 2);
        DataBaseVO beforeLastYearDataBase = setDataBaseVO(beforeLastDataBaseCountList);
        echartsVO.setYearBeforeLastDataBase(beforeLastYearDataBase);

        map.put(STR_DATA, echartsVO);
        return map;
    }

    @RequestMapping("/getJobSalaryData.action")
    @ResponseBody
    public Map<String, Object> getJobSalaryData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        SalaryVO thisYearSalary = academicService.getJobSalaryCount(year);
        echartsVO.setThisYearSalary(thisYearSalary);
        map.put(STR_DATA, echartsVO);
        return map;
    }

    @RequestMapping("/getJobRateData.action")
    @ResponseBody
    public Map<String, Object> getJobRateData(int year) {
        Map<String, Object> map = new HashMap<>();
        EchartsVO echartsVO = new EchartsVO();
        //获取当前年份毕业生总人数
        Long studentTotal = academicService.getStudentTotal(year);
        echartsVO.setYearTotal(studentTotal);
        //获取已经就业的毕业生人数
        Long internshipCount = academicService.getJobCount(year);
        echartsVO.setYearCount(internshipCount);
        if (studentTotal >= internshipCount) {
            echartsVO.setNoYearCount(studentTotal - internshipCount);
        }

        map.put(STR_DATA, echartsVO);
        return map;
    }

}
